package com.jinsi.service.tang.iml;

import com.jinsi.constant.TangConstant;
import com.jinsi.mapper.tang.CommodityReviewMapper;
import com.jinsi.pojo.Commodity;
import com.jinsi.service.tang.CommodityReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 审核商品列表
 * @author 唐文博
 * @Date 2022-08-15
 */
@Service
@Transactional
public class CommodityReviewServiceImpl implements CommodityReviewService {
    @Autowired
    private CommodityReviewMapper commodityReviewMapper;

    /**
     * 筛选搜索查询,根据商品名称、商品分类、上传人查询
     * @param commodityName
     * @param classifyTitle
     * @param classifyId
     * @param userName
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Commodity> getCommodityReviewSee(String commodityName, String classifyTitle,
                                                 Integer classifyId, String userName) {
        return commodityReviewMapper.getCommodityReviewSee(commodityName,classifyTitle,classifyId,
                userName,TangConstant.COMMODITY_ISDEL);
    }

    /**
     * 修改审核状态 1为已审核
     * @param commodityId
     */
    @Override
    public void deleteCommodityReview(Integer commodityId) {
        commodityReviewMapper.deleteCommodityReview(commodityId, TangConstant.EXAMINE_DISPLAY);
    }

    /**
     * 修改审核状态 驳回 为0 未通过 reject
     * @param commodityId
     */
    @Override
    public void deleteReject(Integer commodityId) {
        commodityReviewMapper.deleteReject(commodityId,TangConstant.EXAMINE_FOR_REVIEW);
    }

    /**
     * 查看审核通过的商品  1
     * @param commodityExamine
     * @return
     */
    @Override
    public List<Commodity> getCommodityReviewExamineNormal(Integer commodityExamine) {
        return commodityReviewMapper.getCommodityReviewExamineNormal(commodityExamine,TangConstant.COMMODITY_ISDEL);
    }

}
